import {
  Menu as IconMenu,
  House
} from '@element-plus/icons-vue'

/**
 *  注意： name 必须和 组件命名一样 否则不能keepAlive缓存
 */

const indexRoutes = [
  {
    path: '/home',
    name: 'home',
    meta:{label: '首页',icon:House, keepAlive:false},
    component: () => import('@/pages/home/home.vue')
  },
  {
    meta:{label:'示例',icon:IconMenu},
    name:"exampleMenu",
    path:'/exampleMenu',
    children:[
      {
        path: '/exampleMenu/example',
        name: 'example',
        meta:{label: '示例模板',keepAlive:true},
        component: () => import('@/pages/example/example.vue')
      },
      {
        path: '/exampleMenu/test',
        name: 'test',
        meta:{label: '测试jsx',keepAlive:true},
        component: () => import('@/pages/example/test.vue')
      }
    
    ]
  }
  
]
//路由
export const PageRoutes = ()=>{
  const routes:any[] = [];
  const addRoute = (menuData:any[])=>{
    for(let i =0;i<menuData.length;i++) {
      const item = menuData[i];
      if(!item.children){
        routes.push(item)
      }else{
        addRoute(item.children);
      }
    }
  }
  addRoute(indexRoutes);
  return routes;
};

//菜单
export const MenuRoutes = ()=>{
  return indexRoutes;
};
